home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
GameKit
/
gamekit-1
/
BonusTracker.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
1KB
|
77 lines
#import <gamekit/gamekit.h>
#import <ansi/math.h>
#define PUTINBOUNDS if (value < min) value = min; \
if (value > max) value = max
@implementation BonusTracker
- init
{
[super init];
min = 0;
increment = 0;
multiplier = 1;
baseValue = 0;
max = MAXINT;
[self resetBonus];
return self;
}
- (int)bonusValue
{
return value;
}
- setBaseValue:(int)newValue
{
baseValue = newValue;
return self;
}
- setMultiplier:(int)newMultiplier
{
multiplier = newMultiplier;
return self;
}
- setIncrement:(int)newIncrement
{
increment = newIncrement;
return self;
}
- setMin:(int)newMin max:(int)newMax
{
min = newMin; max = newMax;
PUTINBOUNDS;
return self;
}
- resetBonus
{
value = baseValue;
return self;
}
- advanceBonus // move to the next bonus value.
{
value *= multiplier;
value += increment;
PUTINBOUNDS;
return self;
}
- retreatBonus // inverse of above method.
{
value -= increment;
// avoid divide by zero...
if (multiplier) value /= multiplier;
PUTINBOUNDS;
return self;
}
@end